/*
 * WhileInstructionDescription.java
 * 
 * last update: 16.01.2010 by Stefan Saru
 * 
 * author:	Power(power@kermit.cs.pub.ro)
 * 
 * Obs:
 */

package engine;

@SuppressWarnings("serial")
class WhileInstructionDescription extends InstructionDescription{
	ExpressionDescription ed;
	InstructionDescription id;

	WhileInstructionDescription(int db, int line, NameSpaceDescription nsd,
			ExpressionDescription ed, InstructionDescription id){
		super(db, line, nsd);
		this.ed = ed;
		this.id = id;
	}

	DefaultInstruction instantiate(NameSpace ns)throws ParseException{

		Expression ex;
		try{
			ex = ed.instantiate(ns);
		}catch(ParseException exc){
			xConsole.dumpStack(exc);
			throw new ParseException(super.toString() + " error:" + exc);
		}

		return new WhileInstruction(ns, delayBefore, this, ex, id.instantiate(ns),
				next == null ? null : next.instantiate(ns));
	}

	public String toString(){
		return super.toString() + "while( " + ed + " )";
	}
}




